<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_CreateTable_Commodity extends CI_Migration
{
    public function up()
    {
        $this->dbforge->add_field('id');
        $this->dbforge->add_field(array(
            'title'                  => array('type' => 'VARCHAR', 'constraint' => '50',),
            'content'                => array('type' => 'TEXT',),
            'price'                  => array('type' => 'INT', 'constraint' => '9', 'null' => TRUE,),
            'stock'                  => array('type' => 'INT', 'constraint' => '9', 'null' => TRUE,),
            'contact'                => array('type' => 'VARCHAR', 'constraint' => '50',),
            'release_type'           => array('type' => 'TINYINT', 'constraint' => '1', 'null' => TRUE,),
            'release_time'           => array('type' => 'DATETIME',),
            'image_hash'             => array('type' => 'VARCHAR', 'constraint' => '100', 'null' => TRUE,),
            'user_id'                => array('type' => 'INT', 'constraint' => '9',),
            'commodity_cat_id'       => array('type' => 'INT', 'constraint' => '9', 'null' => TRUE,),
            'commodity_tags_id_json' => array('type' => 'TEXT', 'null' => TRUE,),
        ));
        $this->dbforge->create_table('commodity');
    }

    public function down()
    {
        $this->dbforge->drop_table('commodity');
    }
} 